import http from "./http"

// 获取请假类型
const getAbsentTypes = () => {
  const path = '/absent/type'
  return http.get(path)
}

// 获取审批者
const getResponder = () => {
  const path = '/absent/responder'
  return http.get(path)
}

// 发起请假审批
const applyAbsent = (data) => {
  const path = '/absent/absent'
  return http.post(path, data)
}

// 获取个人请假审批列表
const getMyAbsents = (page = 1) => {
  const path = "/absent/absent?who=my&page=" + page
  return http.get(path)
}

const getSubAbsents = (page = 1) => {
  const path = "/absent/absent?who=sub&page=" + page
  return http.get(path)
}


const handleSubAbsent = (absent_id, status, response_content) => {
  const path = "/absent/absent/" + absent_id
  return http.put(path, { status, response_content })
}

export default {
  getAbsentTypes,
  getResponder,
  applyAbsent,
  getMyAbsents,
  getSubAbsents,
  handleSubAbsent
}